package fr.p10.miage.robot;

public class SlotRecharge extends Slot {
	Tache laTache;

	public SlotRecharge(int idSlot) {
		super(idSlot);
		this.laTache = new Tache("Recharger", 0, new Tri3());
	}

	@Override
	// ** Place un robot sur le slot de recharge
	public synchronized void sePlacer(Robot r) {

		if (r.getSlotEnPlace() != null) {
			Base.getInstance().finitAttente(r.getSlotEnPlace());
			r.getSlotEnPlace().setRobotPlace(null);
		}
		r.setSlotEnPlace(this);
		this.robotPlace = r;
		this.robotPlace.getInfoRobot().AjoutRechargement();
		this.laTache.executer();
		this.robotPlace.batteriePleine();

		this.robotPlace = null;
		r.setSlotEnPlace(null);
	}

	@Override
	public String toString() {
		if (this.isOccupe()) {
			return "* Slot de recharge : robot " + this.robotPlace.getIdRobot();
		} else {
			return "* Slot de recharge : vide";
		}
	}
}